blob: d21d513c59a6f15d592c751c3fdc103ce4a96366 [file] [log] [blame]
Daniel Kurtz53b62132018-02-08 11:56:14 -07001/*
2 * This file is part of the coreboot project.
3 *
4 * Copyright 2018 Google LLC
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; version 2 of the License.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 */
15
16#include <arch/acpi_device.h>
17#include <arch/acpigen.h>
18#include <console/console.h>
19#include <device/device.h>
20#include <device/path.h>
21#include <stdint.h>
22#include <string.h>
23#include "chip.h"
24
25#if IS_ENABLED(CONFIG_HAVE_ACPI_TABLES)
26
27#define ADAU7002_ACPI_NAME "ADAU"
28#define ADAU7002_ACPI_HID "ADAU7002"
29
30static void adau7002_fill_ssdt(struct device *dev)
31{
32 if (!dev->enabled)
33 return;
34
35 /* Device */
36 acpigen_write_scope(acpi_device_scope(dev));
37 acpigen_write_device(acpi_device_name(dev));
38 acpigen_write_name_string("_HID", ADAU7002_ACPI_HID);
39 acpigen_write_name_integer("_UID", 0);
40 acpigen_write_name_string("_DDN", dev->chip_ops->name);
41 acpigen_write_STA(ACPI_STATUS_DEVICE_ALL_ON);
42
43 acpigen_pop_len(); /* Device */
44 acpigen_pop_len(); /* Scope */
45
46 printk(BIOS_INFO, "%s: %s\n", acpi_device_path(dev),
47 dev->chip_ops->name);
48}
49
50static const char *adau7002_acpi_name(const struct device *dev)
51{
52 return ADAU7002_ACPI_NAME;
53}
54#endif
55
56static struct device_operations adau7002_ops = {
57 .read_resources = DEVICE_NOOP,
58 .set_resources = DEVICE_NOOP,
59 .enable_resources = DEVICE_NOOP,
60#if IS_ENABLED(CONFIG_HAVE_ACPI_TABLES)
61 .acpi_name = &adau7002_acpi_name,
62 .acpi_fill_ssdt_generator = &adau7002_fill_ssdt,
63#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")
73 .enable_dev = &adau7002_enable
74};