libpayload: configs: Add new config.featuretest to broaden CI
[coreboot.git] / src / mainboard / intel / kunimitsu / mainboard.c
blob19d6a724bf239e574754997bff7c34a528ba6fc3
1 /* SPDX-License-Identifier: GPL-2.0-only */
3 #include <acpi/acpi.h>
4 #include <console/console.h>
5 #include <device/device.h>
6 #include <gpio.h>
7 #include <soc/nhlt.h>
8 #include "ec.h"
9 #include "gpio.h"
11 static const char *oem_id_maxim = "INTEL";
12 static const char *oem_table_id_maxim = "SCRDMAX";
14 static void mainboard_init(struct device *dev)
16 mainboard_ec_init();
19 static uint8_t select_audio_codec(void)
21 int audio_db_sel = gpio_get(AUDIO_DB_ID);
23 return audio_db_sel;
26 static unsigned long mainboard_write_acpi_tables(
27 const struct device *device, unsigned long current, acpi_rsdp_t *rsdp)
29 uintptr_t start_addr;
30 uintptr_t end_addr;
31 struct nhlt *nhlt;
32 const char *oem_id = NULL;
33 const char *oem_table_id = NULL;
35 start_addr = current;
37 nhlt = nhlt_init();
39 if (nhlt == NULL)
40 return start_addr;
42 /* 2 Channel DMIC array. */
43 if (nhlt_soc_add_dmic_array(nhlt, 2))
44 printk(BIOS_ERR, "Couldn't add 2CH DMIC array.\n");
46 /* 4 Channel DMIC array. */
47 if (nhlt_soc_add_dmic_array(nhlt, 4))
48 printk(BIOS_ERR, "Couldn't add 4CH DMIC arrays.\n");
50 if (select_audio_codec()) {
51 /* ADI Smart Amps for left and right. */
52 if (nhlt_soc_add_ssm4567(nhlt, AUDIO_LINK_SSP0))
53 printk(BIOS_ERR, "Couldn't add ssm4567.\n");
54 } else {
55 /* MAXIM Smart Amps for left and right. */
56 if (nhlt_soc_add_max98357(nhlt, AUDIO_LINK_SSP0))
57 printk(BIOS_ERR, "Couldn't add max98357.\n");
59 oem_id = oem_id_maxim;
60 oem_table_id = oem_table_id_maxim;
63 /* NAU88l25 Headset codec. */
64 if (nhlt_soc_add_nau88l25(nhlt, AUDIO_LINK_SSP1))
65 printk(BIOS_ERR, "Couldn't add headset codec.\n");
67 end_addr = nhlt_soc_serialize_oem_overrides(nhlt, start_addr,
68 oem_id, oem_table_id, 0);
70 if (end_addr != start_addr)
71 acpi_add_table(rsdp, (void *)start_addr);
73 return end_addr;
76 static void mainboard_enable(struct device *dev)
78 dev->ops->init = mainboard_init;
79 dev->ops->write_acpi_tables = mainboard_write_acpi_tables;
82 struct chip_operations mainboard_ops = {
83 .enable_dev = mainboard_enable,