Daniel Kurtz | 53b6213 | 2018-02-08 11:56:14 -0700 | [diff] [blame] | 1 | /* |
| 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 | |
| 30 | static void adau7002_fill_ssdt(struct device *dev) |
| 31 | { |
Richard Spiegel | e0d3064 | 2018-02-14 09:38:11 -0700 | [diff] [blame^] | 32 | 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 Kurtz | 53b6213 | 2018-02-08 11:56:14 -0700 | [diff] [blame] | 38 | return; |
| 39 | |
| 40 | /* Device */ |
Richard Spiegel | e0d3064 | 2018-02-14 09:38:11 -0700 | [diff] [blame^] | 41 | acpigen_write_scope(scope); |
| 42 | acpigen_write_device(name); |
Daniel Kurtz | 53b6213 | 2018-02-08 11:56:14 -0700 | [diff] [blame] | 43 | 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); |
| 46 | acpigen_write_STA(ACPI_STATUS_DEVICE_ALL_ON); |
| 47 | |
| 48 | acpigen_pop_len(); /* Device */ |
| 49 | acpigen_pop_len(); /* Scope */ |
| 50 | |
| 51 | printk(BIOS_INFO, "%s: %s\n", acpi_device_path(dev), |
| 52 | dev->chip_ops->name); |
| 53 | } |
| 54 | |
| 55 | static const char *adau7002_acpi_name(const struct device *dev) |
| 56 | { |
| 57 | return ADAU7002_ACPI_NAME; |
| 58 | } |
| 59 | #endif |
| 60 | |
| 61 | static struct device_operations adau7002_ops = { |
| 62 | .read_resources = DEVICE_NOOP, |
| 63 | .set_resources = DEVICE_NOOP, |
| 64 | .enable_resources = DEVICE_NOOP, |
| 65 | #if IS_ENABLED(CONFIG_HAVE_ACPI_TABLES) |
| 66 | .acpi_name = &adau7002_acpi_name, |
| 67 | .acpi_fill_ssdt_generator = &adau7002_fill_ssdt, |
| 68 | #endif |
| 69 | }; |
| 70 | |
| 71 | static void adau7002_enable(struct device *dev) |
| 72 | { |
| 73 | dev->ops = &adau7002_ops; |
| 74 | } |
| 75 | |
| 76 | struct chip_operations drivers_generic_adau7002_ops = { |
| 77 | CHIP_NAME("Analog Digital DMIC") |
| 78 | .enable_dev = &adau7002_enable |
| 79 | }; |