Eric Lai | 16b34ed8 | 2021-02-24 16:28:17 +0800 | [diff] [blame] | 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 "chip.h" |
| 9 | |
| 10 | static void alc1015_fill_ssdt(const struct device *dev) |
| 11 | { |
| 12 | struct drivers_generic_alc1015_config *config = dev->chip_info; |
| 13 | const char *path; |
| 14 | struct acpi_dp *dp; |
| 15 | |
| 16 | if (!config) |
| 17 | return; |
| 18 | |
| 19 | const char *scope = acpi_device_scope(dev); |
| 20 | const char *name = acpi_device_name(dev); |
| 21 | if (!scope || !name) |
| 22 | return; |
| 23 | |
| 24 | /* Device */ |
| 25 | acpigen_write_scope(scope); |
| 26 | acpigen_write_device(name); |
| 27 | |
Eric Lai | b6f6e01 | 2021-08-09 14:54:00 +0800 | [diff] [blame] | 28 | if (config->hid) |
| 29 | acpigen_write_name_string("_HID", config->hid); |
| 30 | else |
| 31 | acpigen_write_name_string("_HID", "RTL1015"); |
Eric Lai | 16b34ed8 | 2021-02-24 16:28:17 +0800 | [diff] [blame] | 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)); |
| 35 | |
| 36 | /* Resources */ |
| 37 | acpigen_write_name("_CRS"); |
| 38 | acpigen_write_resourcetemplate_header(); |
| 39 | acpi_device_write_gpio(&config->sdb); |
| 40 | acpigen_write_resourcetemplate_footer(); |
| 41 | |
| 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"); |
Eric Lai | d8e6d3e | 2021-03-09 21:36:01 +0800 | [diff] [blame] | 46 | acpi_dp_add_gpio(dp, "sdb-gpios", path, 0, 0, config->sdb.active_low); |
| 47 | acpi_dp_write(dp); |
Eric Lai | 16b34ed8 | 2021-02-24 16:28:17 +0800 | [diff] [blame] | 48 | |
| 49 | acpigen_pop_len(); /* Device */ |
| 50 | acpigen_pop_len(); /* Scope */ |
| 51 | |
| 52 | printk(BIOS_INFO, "%s: %s\n", path, dev->chip_ops->name); |
| 53 | } |
| 54 | |
| 55 | static const char *alc1015_acpi_name(const struct device *dev) |
| 56 | { |
| 57 | return "ALCP"; |
| 58 | } |
| 59 | |
| 60 | static struct device_operations alc1015_ops = { |
| 61 | .read_resources = noop_read_resources, |
| 62 | .set_resources = noop_set_resources, |
| 63 | .acpi_name = alc1015_acpi_name, |
| 64 | .acpi_fill_ssdt = alc1015_fill_ssdt, |
| 65 | }; |
| 66 | |
| 67 | static void alc1015_enable(struct device *dev) |
| 68 | { |
| 69 | dev->ops = &alc1015_ops; |
| 70 | } |
| 71 | |
| 72 | struct chip_operations drivers_generic_alc1015_ops = { |
Nicholas Sudsgaard | bfb11be | 2024-01-30 09:53:46 +0900 | [diff] [blame^] | 73 | .name = "ASoC RT1015P Amplifier driver", |
Eric Lai | 16b34ed8 | 2021-02-24 16:28:17 +0800 | [diff] [blame] | 74 | .enable_dev = alc1015_enable |
| 75 | }; |