blob: 257775e763e4739737fca0d12deb72114a678997 [file] [log] [blame]
Eric Lai16b34ed82021-02-24 16:28:17 +08001/* 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>
Eric Lai16b34ed82021-02-24 16:28:17 +08007#include "chip.h"
8
9static void alc1015_fill_ssdt(const struct device *dev)
10{
11 struct drivers_generic_alc1015_config *config = dev->chip_info;
12 const char *path;
13 struct acpi_dp *dp;
14
15 if (!config)
16 return;
17
18 const char *scope = acpi_device_scope(dev);
19 const char *name = acpi_device_name(dev);
20 if (!scope || !name)
21 return;
22
23 /* Device */
24 acpigen_write_scope(scope);
25 acpigen_write_device(name);
26
Eric Laib6f6e012021-08-09 14:54:00 +080027 if (config->hid)
28 acpigen_write_name_string("_HID", config->hid);
29 else
30 acpigen_write_name_string("_HID", "RTL1015");
Eric Lai16b34ed82021-02-24 16:28:17 +080031 acpigen_write_name_integer("_UID", 0);
32 acpigen_write_name_string("_DDN", dev->chip_ops->name);
33 acpigen_write_STA(acpi_device_status(dev));
34
35 /* Resources */
36 acpigen_write_name("_CRS");
37 acpigen_write_resourcetemplate_header();
38 acpi_device_write_gpio(&config->sdb);
39 acpigen_write_resourcetemplate_footer();
40
41 /* _DSD for devicetree properties */
42 /* This points to the first pin in the first gpio entry in _CRS */
43 path = acpi_device_path(dev);
44 dp = acpi_dp_new_table("_DSD");
Eric Laid8e6d3e2021-03-09 21:36:01 +080045 acpi_dp_add_gpio(dp, "sdb-gpios", path, 0, 0, config->sdb.active_low);
46 acpi_dp_write(dp);
Eric Lai16b34ed82021-02-24 16:28:17 +080047
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
54static const char *alc1015_acpi_name(const struct device *dev)
55{
56 return "ALCP";
57}
58
59static struct device_operations alc1015_ops = {
60 .read_resources = noop_read_resources,
61 .set_resources = noop_set_resources,
62 .acpi_name = alc1015_acpi_name,
63 .acpi_fill_ssdt = alc1015_fill_ssdt,
64};
65
66static void alc1015_enable(struct device *dev)
67{
68 dev->ops = &alc1015_ops;
69}
70
71struct chip_operations drivers_generic_alc1015_ops = {
Nicholas Sudsgaardbfb11be2024-01-30 09:53:46 +090072 .name = "ASoC RT1015P Amplifier driver",
Eric Lai16b34ed82021-02-24 16:28:17 +080073 .enable_dev = alc1015_enable
74};