blob: db48bfe24f52dbc3861f456cd790efbe6199ed77 [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>
Daniel Kurtz53b62132018-02-08 11:56:14 -07007#include "chip.h"
8
Julius Wernercd49cce2019-03-05 16:53:33 -08009#if CONFIG(HAVE_ACPI_TABLES)
Daniel Kurtz53b62132018-02-08 11:56:14 -070010
11#define ADAU7002_ACPI_NAME "ADAU"
12#define ADAU7002_ACPI_HID "ADAU7002"
13
Furquan Shaikh7536a392020-04-24 21:59:21 -070014static void adau7002_fill_ssdt(const struct device *dev)
Daniel Kurtz53b62132018-02-08 11:56:14 -070015{
Akshu Agrawal7ac31492019-01-08 14:06:42 +053016 struct drivers_generic_adau7002_config *config;
17 struct acpi_dp *dp;
18
Karthikeyan Ramasubramaniand1c0f952020-11-02 16:26:52 -070019 if (!dev)
Richard Spiegele0d30642018-02-14 09:38:11 -070020 return;
21
22 const char *scope = acpi_device_scope(dev);
23 const char *name = acpi_device_name(dev);
24 if (!scope || !name)
Daniel Kurtz53b62132018-02-08 11:56:14 -070025 return;
26
27 /* Device */
Richard Spiegele0d30642018-02-14 09:38:11 -070028 acpigen_write_scope(scope);
29 acpigen_write_device(name);
Daniel Kurtz53b62132018-02-08 11:56:14 -070030 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 DeVillier44d0a132023-10-17 15:08:20 -050033 acpigen_write_STA(ACPI_STATUS_DEVICE_HIDDEN_ON);
Daniel Kurtz53b62132018-02-08 11:56:14 -070034
Akshu Agrawal7ac31492019-01-08 14:06:42 +053035 /* _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 Kurtz53b62132018-02-08 11:56:14 -070041 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
48static const char *adau7002_acpi_name(const struct device *dev)
49{
50 return ADAU7002_ACPI_NAME;
51}
52#endif
53
54static struct device_operations adau7002_ops = {
Nico Huber2f8ba692020-04-05 14:05:24 +020055 .read_resources = noop_read_resources,
56 .set_resources = noop_set_resources,
Julius Wernercd49cce2019-03-05 16:53:33 -080057#if CONFIG(HAVE_ACPI_TABLES)
Nico Huber68680dd2020-03-31 17:34:52 +020058 .acpi_name = adau7002_acpi_name,
59 .acpi_fill_ssdt = adau7002_fill_ssdt,
Daniel Kurtz53b62132018-02-08 11:56:14 -070060#endif
61};
62
63static void adau7002_enable(struct device *dev)
64{
65 dev->ops = &adau7002_ops;
66}
67
68struct chip_operations drivers_generic_adau7002_ops = {
Nicholas Sudsgaardbfb11be2024-01-30 09:53:46 +090069 .name = "Analog Digital DMIC",
Elyes HAOUAS2aa3b162018-11-27 17:02:10 +010070 .enable_dev = adau7002_enable
Daniel Kurtz53b62132018-02-08 11:56:14 -070071};