coreboot
coreboot is an Open Source project aimed at replacing the proprietary BIOS found in most computers.
nau8315.c
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 
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"
10 
11 static void nau8315_fill_ssdt(const struct device *dev)
12 {
14  const char *path;
15  struct acpi_dp *dp;
16 
17  if (!dev->enabled || !config)
18  return;
19 
20  const char *scope = acpi_device_scope(dev);
21  const char *name = acpi_device_name(dev);
22  if (!scope || !name)
23  return;
24 
25  /* Device */
26  acpigen_write_scope(scope);
28 
29  acpigen_write_name_string("_HID", "NVTN2010");
30  acpigen_write_name_integer("_UID", 0);
33 
34  /* Resources */
35  acpigen_write_name("_CRS");
37  acpi_device_write_gpio(&config->enable_gpio);
39 
40  /* _DSD for devicetree properties */
41  /* This points to the first pin in the first gpio entry in _CRS */
42  path = acpi_device_path(dev);
43  dp = acpi_dp_new_table("_DSD");
44  acpi_dp_add_gpio(dp, "enable-gpios", path, 0, 0,
45  config->enable_gpio.active_low);
46  acpi_dp_write(dp);
47 
48  acpigen_pop_len(); /* Device */
49  acpigen_pop_len(); /* Scope */
50 
51  printk(BIOS_INFO, "%s: %s\n", path, dev->chip_ops->name);
52 }
53 
54 static const char *nau8315_acpi_name(const struct device *dev)
55 {
56  return "NVTN";
57 }
58 
59 static struct device_operations nau8315_ops = {
61  .set_resources = noop_set_resources,
62  .acpi_name = nau8315_acpi_name,
63  .acpi_fill_ssdt = nau8315_fill_ssdt,
64 };
65 
66 static void nau8315_enable(struct device *dev)
67 {
68  dev->ops = &nau8315_ops;
69 }
70 
72  CHIP_NAME("Nuvoton NAU8315 Amplifier")
73  .enable_dev = nau8315_enable
74 };
void acpi_device_write_gpio(const struct acpi_gpio *gpio)
Definition: device.c:258
const char * acpi_device_path(const struct device *dev)
Definition: device.c:144
void acpi_dp_write(struct acpi_dp *table)
Definition: device.c:898
struct acpi_dp * acpi_dp_add_gpio(struct acpi_dp *dp, const char *name, const char *ref, int index, int pin, int active_low)
Definition: device.c:1142
int acpi_device_status(const struct device *dev)
Definition: device.c:193
const char * acpi_device_name(const struct device *dev)
Definition: device.c:49
struct acpi_dp * acpi_dp_new_table(const char *name)
Definition: device.c:930
const char * acpi_device_scope(const struct device *dev)
Definition: device.c:158
void acpigen_pop_len(void)
Definition: acpigen.c:37
void acpigen_write_scope(const char *name)
Definition: acpigen.c:326
void acpigen_write_resourcetemplate_footer(void)
Definition: acpigen.c:1165
void acpigen_write_name_integer(const char *name, uint64_t val)
Definition: acpigen.c:170
void acpigen_write_STA(uint8_t status)
Definition: acpigen.c:783
void acpigen_write_resourcetemplate_header(void)
Definition: acpigen.c:1147
void acpigen_write_device(const char *name)
Definition: acpigen.c:769
void acpigen_write_name(const char *name)
Definition: acpigen.c:320
void acpigen_write_name_string(const char *name, const char *string)
Definition: acpigen.c:176
const char * name
Definition: mmu.c:92
#define printk(level,...)
Definition: stdlib.h:16
#define CHIP_NAME(X)
Definition: device.h:32
static void noop_read_resources(struct device *dev)
Standard device operations function pointers shims.
Definition: device.h:73
static void noop_set_resources(struct device *dev)
Definition: device.h:74
#define BIOS_INFO
BIOS_INFO - Expected events.
Definition: loglevel.h:113
enum board_config config
Definition: memory.c:448
static const char * nau8315_acpi_name(const struct device *dev)
Definition: nau8315.c:54
static void nau8315_enable(struct device *dev)
Definition: nau8315.c:66
static void nau8315_fill_ssdt(const struct device *dev)
Definition: nau8315.c:11
static struct device_operations nau8315_ops
Definition: nau8315.c:59
struct chip_operations drivers_generic_nau8315_ops
Definition: nau8315.c:71
const char * name
Definition: device.h:29
void(* read_resources)(struct device *dev)
Definition: device.h:39
Definition: device.h:107
struct chip_operations * chip_ops
Definition: device.h:144
struct device_operations * ops
Definition: device.h:143
DEVTREE_CONST void * chip_info
Definition: device.h:164
unsigned int enabled
Definition: device.h:122