1 /* SPDX-License-Identifier: GPL-2.0-only */
4 #include <baseboard/variant.h>
5 #include <console/console.h>
6 #include <device/device.h>
9 #include <variant/gpio.h>
12 static const char *oem_id_maxim
= "INTEL";
13 static const char *oem_table_id_maxim
= "SCRDMAX";
15 static void mainboard_init(struct device
*dev
)
20 static uint8_t adi_codec_enable(void)
23 return gpio_get(AUDIO_DB_ID
);
29 static uint8_t max_codec_enable(void)
32 return gpio_get(AUDIO_DB_ID
) ? 0 : 1;
38 static unsigned long mainboard_write_acpi_tables(
39 const struct device
*device
, unsigned long current
, acpi_rsdp_t
*rsdp
)
44 const char *oem_id
= NULL
;
45 const char *oem_table_id
= NULL
;
54 /* 2 Channel DMIC array. */
55 if (nhlt_soc_add_dmic_array(nhlt
, 2))
56 printk(BIOS_ERR
, "Couldn't add 2CH DMIC array.\n");
58 /* 4 Channel DMIC array. */
59 if (CONFIG(NHLT_DMIC_4CH
))
60 if (nhlt_soc_add_dmic_array(nhlt
, 4))
61 printk(BIOS_ERR
, "Couldn't add 4CH DMIC arrays.\n");
63 /* ADI Smart Amps for left and right. */
64 if (CONFIG(NHLT_SSM4567
) && adi_codec_enable())
65 if (nhlt_soc_add_ssm4567(nhlt
, AUDIO_LINK_SSP0
))
66 printk(BIOS_ERR
, "Couldn't add ssm4567.\n");
68 /* MAXIM Smart Amps for left and right. */
69 if (CONFIG(NHLT_MAX98357
) && max_codec_enable()) {
70 if (nhlt_soc_add_max98357(nhlt
, AUDIO_LINK_SSP0
))
71 printk(BIOS_ERR
, "Couldn't add max98357.\n");
73 oem_id
= oem_id_maxim
;
74 oem_table_id
= oem_table_id_maxim
;
77 /* NAU88l25 Headset codec. */
78 if (nhlt_soc_add_nau88l25(nhlt
, AUDIO_LINK_SSP1
))
79 printk(BIOS_ERR
, "Couldn't add headset codec.\n");
81 end_addr
= nhlt_soc_serialize_oem_overrides(nhlt
, start_addr
,
82 oem_id
, oem_table_id
, 0);
84 if (end_addr
!= start_addr
)
85 acpi_add_table(rsdp
, (void *)start_addr
);
91 * mainboard_enable is executed as first thing after
94 static void mainboard_enable(struct device
*dev
)
96 dev
->ops
->init
= mainboard_init
;
97 dev
->ops
->write_acpi_tables
= mainboard_write_acpi_tables
;
100 static void mainboard_chip_init(void *chip_info
)
102 /* Configure pads prior to SiliconInit() in case there's any
103 * dependencies during hardware initialization. */
104 gpio_configure_pads(gpio_table
, ARRAY_SIZE(gpio_table
));
107 struct chip_operations mainboard_ops
= {
108 .init
= mainboard_chip_init
,
109 .enable_dev
= mainboard_enable
,