blob: ddf6b7a93ead1020818bc36413eaa4289853dcaf [file] [log] [blame]
Angel Pons8a3453f2020-04-02 23:48:19 +02001/* SPDX-License-Identifier: GPL-2.0-only */
2/* This file is part of the coreboot project. */
Daniel Kurtz53b62132018-02-08 11:56:14 -07003
Furquan Shaikh76cedd22020-05-02 10:24:23 -07004#include <acpi/acpi_device.h>
5#include <acpi/acpigen.h>
Daniel Kurtz53b62132018-02-08 11:56:14 -07006#include <console/console.h>
7#include <device/device.h>
8#include <device/path.h>
9#include <stdint.h>
Daniel Kurtz53b62132018-02-08 11:56:14 -070010#include "chip.h"
11
Julius Wernercd49cce2019-03-05 16:53:33 -080012#if CONFIG(HAVE_ACPI_TABLES)
Daniel Kurtz53b62132018-02-08 11:56:14 -070013
14#define ADAU7002_ACPI_NAME "ADAU"
15#define ADAU7002_ACPI_HID "ADAU7002"
16
Furquan Shaikh7536a392020-04-24 21:59:21 -070017static void adau7002_fill_ssdt(const struct device *dev)
Daniel Kurtz53b62132018-02-08 11:56:14 -070018{
Akshu Agrawal7ac31492019-01-08 14:06:42 +053019 struct drivers_generic_adau7002_config *config;
20 struct acpi_dp *dp;
21
Richard Spiegele0d30642018-02-14 09:38:11 -070022 if (!dev || !dev->enabled)
23 return;
24
25 const char *scope = acpi_device_scope(dev);
26 const char *name = acpi_device_name(dev);
27 if (!scope || !name)
Daniel Kurtz53b62132018-02-08 11:56:14 -070028 return;
29
30 /* Device */
Richard Spiegele0d30642018-02-14 09:38:11 -070031 acpigen_write_scope(scope);
32 acpigen_write_device(name);
Daniel Kurtz53b62132018-02-08 11:56:14 -070033 acpigen_write_name_string("_HID", ADAU7002_ACPI_HID);
34 acpigen_write_name_integer("_UID", 0);
35 acpigen_write_name_string("_DDN", dev->chip_ops->name);
Hung-Te Linb4be50c2018-09-10 10:55:49 +080036 acpigen_write_STA(acpi_device_status(dev));
Daniel Kurtz53b62132018-02-08 11:56:14 -070037
Akshu Agrawal7ac31492019-01-08 14:06:42 +053038 /* _DSD for devicetree properties */
39 config = dev->chip_info;
40 dp = acpi_dp_new_table("_DSD");
41 acpi_dp_add_integer(dp, "wakeup-delay-ms", config->wakeup_delay);
42 acpi_dp_write(dp);
43
Daniel Kurtz53b62132018-02-08 11:56:14 -070044 acpigen_pop_len(); /* Device */
45 acpigen_pop_len(); /* Scope */
46
47 printk(BIOS_INFO, "%s: %s\n", acpi_device_path(dev),
48 dev->chip_ops->name);
49}
50
51static const char *adau7002_acpi_name(const struct device *dev)
52{
53 return ADAU7002_ACPI_NAME;
54}
55#endif
56
57static struct device_operations adau7002_ops = {
Nico Huber2f8ba692020-04-05 14:05:24 +020058 .read_resources = noop_read_resources,
59 .set_resources = noop_set_resources,
Julius Wernercd49cce2019-03-05 16:53:33 -080060#if CONFIG(HAVE_ACPI_TABLES)
Nico Huber68680dd2020-03-31 17:34:52 +020061 .acpi_name = adau7002_acpi_name,
62 .acpi_fill_ssdt = adau7002_fill_ssdt,
Daniel Kurtz53b62132018-02-08 11:56:14 -070063#endif
64};
65
66static void adau7002_enable(struct device *dev)
67{
68 dev->ops = &adau7002_ops;
69}
70
71struct chip_operations drivers_generic_adau7002_ops = {
72 CHIP_NAME("Analog Digital DMIC")
Elyes HAOUAS2aa3b162018-11-27 17:02:10 +010073 .enable_dev = adau7002_enable
Daniel Kurtz53b62132018-02-08 11:56:14 -070074};