soc/intel/alderlake: Add ADL-P 4+4 with 28W TDP
[coreboot.git] / src / drivers / generic / nau8315 / nau8315.c
blobac2bfd1b55ad71af2deba4fb52c2f41a8523d94b
1 /* SPDX-License-Identifier: GPL-2.0-only */
3 #include <acpi/acpi_device.h>
4 #include <acpi/acpigen.h>
5 #include <console/console.h>
6 #include <device/device.h>
7 #include <device/path.h>
8 #include <gpio.h>
9 #include "chip.h"
11 const char *nauhid[MAX_HID] = {"NVTN2010", "NVTN2012"};
13 static void nau8315_fill_ssdt(const struct device *dev)
15 struct drivers_generic_nau8315_config *config = dev->chip_info;
16 const char *path;
17 struct acpi_dp *dp;
19 if (!dev->enabled || !config)
20 return;
22 const char *scope = acpi_device_scope(dev);
23 const char *name = acpi_device_name(dev);
24 if (!scope || !name)
25 return;
27 /* Device */
28 acpigen_write_scope(scope);
29 acpigen_write_device(name);
31 acpigen_write_name_string("_HID", nauhid[config->hid]);
32 acpigen_write_name_integer("_UID", 0);
33 acpigen_write_name_string("_DDN", dev->chip_ops->name);
34 acpigen_write_STA(acpi_device_status(dev));
36 /* Resources */
37 acpigen_write_name("_CRS");
38 acpigen_write_resourcetemplate_header();
39 acpi_device_write_gpio(&config->enable_gpio);
40 acpigen_write_resourcetemplate_footer();
42 /* _DSD for devicetree properties */
43 /* This points to the first pin in the first gpio entry in _CRS */
44 path = acpi_device_path(dev);
45 dp = acpi_dp_new_table("_DSD");
46 acpi_dp_add_gpio(dp, "enable-gpios", path, 0, 0,
47 config->enable_gpio.active_low);
48 acpi_dp_write(dp);
50 acpigen_pop_len(); /* Device */
51 acpigen_pop_len(); /* Scope */
53 printk(BIOS_INFO, "%s: %s\n", path, dev->chip_ops->name);
56 static const char *nau8315_acpi_name(const struct device *dev)
58 return "NVTN";
61 static struct device_operations nau8315_ops = {
62 .read_resources = noop_read_resources,
63 .set_resources = noop_set_resources,
64 .acpi_name = nau8315_acpi_name,
65 .acpi_fill_ssdt = nau8315_fill_ssdt,
68 static void nau8315_enable(struct device *dev)
70 dev->ops = &nau8315_ops;
73 struct chip_operations drivers_generic_nau8315_ops = {
74 CHIP_NAME("Nuvoton NAU8315 Amplifier")
75 .enable_dev = nau8315_enable