blob: 0a3d62357bb49cc5851b463d9d37e15e4abb9f19 [file] [log] [blame]
Daniel Kurtz53b62132018-02-08 11:56:14 -07001/*
2 * This file is part of the coreboot project.
3 *
Daniel Kurtz53b62132018-02-08 11:56:14 -07004 * 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 Kurtz53b62132018-02-08 11:56:14 -070020#include "chip.h"
21
Julius Wernercd49cce2019-03-05 16:53:33 -080022#if CONFIG(HAVE_ACPI_TABLES)
Daniel Kurtz53b62132018-02-08 11:56:14 -070023
24#define ADAU7002_ACPI_NAME "ADAU"
25#define ADAU7002_ACPI_HID "ADAU7002"
26
27static void adau7002_fill_ssdt(struct device *dev)
28{
Akshu Agrawal7ac31492019-01-08 14:06:42 +053029 struct drivers_generic_adau7002_config *config;
30 struct acpi_dp *dp;
31
Richard Spiegele0d30642018-02-14 09:38:11 -070032 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 Kurtz53b62132018-02-08 11:56:14 -070038 return;
39
40 /* Device */
Richard Spiegele0d30642018-02-14 09:38:11 -070041 acpigen_write_scope(scope);
42 acpigen_write_device(name);
Daniel Kurtz53b62132018-02-08 11:56:14 -070043 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 Linb4be50c2018-09-10 10:55:49 +080046 acpigen_write_STA(acpi_device_status(dev));
Daniel Kurtz53b62132018-02-08 11:56:14 -070047
Akshu Agrawal7ac31492019-01-08 14:06:42 +053048 /* _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 Kurtz53b62132018-02-08 11:56:14 -070054 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
61static const char *adau7002_acpi_name(const struct device *dev)
62{
63 return ADAU7002_ACPI_NAME;
64}
65#endif
66
67static struct device_operations adau7002_ops = {
Nico Huber68680dd2020-03-31 17:34:52 +020068 .read_resources = DEVICE_NOOP,
69 .set_resources = DEVICE_NOOP,
70 .enable_resources = DEVICE_NOOP,
Julius Wernercd49cce2019-03-05 16:53:33 -080071#if CONFIG(HAVE_ACPI_TABLES)
Nico Huber68680dd2020-03-31 17:34:52 +020072 .acpi_name = adau7002_acpi_name,
73 .acpi_fill_ssdt = adau7002_fill_ssdt,
Daniel Kurtz53b62132018-02-08 11:56:14 -070074#endif
75};
76
77static void adau7002_enable(struct device *dev)
78{
79 dev->ops = &adau7002_ops;
80}
81
82struct chip_operations drivers_generic_adau7002_ops = {
83 CHIP_NAME("Analog Digital DMIC")
Elyes HAOUAS2aa3b162018-11-27 17:02:10 +010084 .enable_dev = adau7002_enable
Daniel Kurtz53b62132018-02-08 11:56:14 -070085};