blob: 916775fc4bd7f8af31f01171a089d3ee1ea278c9 [file] [log] [blame]
Angel Pons0612b272020-04-05 15:46:56 +02001/* SPDX-License-Identifier: GPL-2.0-only */
Duncan Laurie93142a42018-01-08 17:41:58 -08002
3#include <console/console.h>
4#include <device/device.h>
5#include <device/azalia_device.h>
6#include <device/pci.h>
7#include <device/pci_ids.h>
Duncan Laurie93142a42018-01-08 17:41:58 -08008#include <soc/intel/common/hda_verb.h>
9#include <soc/ramstage.h>
10
Julius Wernercd49cce2019-03-05 16:53:33 -080011#if CONFIG(SOC_INTEL_COMMON_BLOCK_HDA_VERB)
Duncan Laurie93142a42018-01-08 17:41:58 -080012static void codecs_init(uint8_t *base, u32 codec_mask)
13{
14 int i;
15
16 /* Can support up to 4 codecs */
17 for (i = 3; i >= 0; i--) {
18 if (codec_mask & (1 << i))
19 hda_codec_init(base, i,
20 cim_verb_data_size, cim_verb_data);
21 }
22
23 if (pc_beep_verbs_size)
24 hda_codec_write(base, pc_beep_verbs_size, pc_beep_verbs);
25}
26
27static void hda_init(struct device *dev)
28{
29 struct resource *res;
30 int codec_mask;
31 uint8_t *base;
32
33 res = find_resource(dev, PCI_BASE_ADDRESS_0);
34 if (!res)
35 return;
36
37 base = res2mmio(res, 0, 0);
38 if (!base)
39 return;
40
41 codec_mask = hda_codec_detect(base);
42 if (codec_mask) {
43 printk(BIOS_INFO, "HDA: codec_mask = %02x\n", codec_mask);
44 codecs_init(base, codec_mask);
45 }
46}
Furquan Shaikh31bff012018-09-29 23:31:04 -070047#endif
Duncan Laurie93142a42018-01-08 17:41:58 -080048
49static struct device_operations hda_ops = {
Elyes HAOUAS1d191272018-11-27 12:23:48 +010050 .read_resources = pci_dev_read_resources,
51 .set_resources = pci_dev_set_resources,
52 .enable_resources = pci_dev_enable_resources,
Julius Wernercd49cce2019-03-05 16:53:33 -080053#if CONFIG(SOC_INTEL_COMMON_BLOCK_HDA_VERB)
Elyes HAOUAS1d191272018-11-27 12:23:48 +010054 .init = hda_init,
Furquan Shaikh31bff012018-09-29 23:31:04 -070055#endif
Duncan Laurie93142a42018-01-08 17:41:58 -080056 .ops_pci = &pci_dev_ops_pci,
Nico Huberf7ed3d42019-03-14 15:50:06 +010057 .scan_bus = enable_static_devices,
Duncan Laurie93142a42018-01-08 17:41:58 -080058};
59
60static const unsigned short pci_device_ids[] = {
61 PCI_DEVICE_ID_INTEL_SKL_AUDIO,
Praveen hodagatta praneshccd7cd82018-11-23 17:30:39 +080062 PCI_DEVICE_ID_INTEL_SKL_H_AUDIO,
Maxim Polyakov571d07d2019-08-22 13:11:32 +030063 PCI_DEVICE_ID_INTEL_LWB_AUDIO,
64 PCI_DEVICE_ID_INTEL_LWB_AUDIO_SUPER,
Duncan Laurie93142a42018-01-08 17:41:58 -080065 PCI_DEVICE_ID_INTEL_KBL_AUDIO,
66 PCI_DEVICE_ID_INTEL_CNL_AUDIO,
praveen hodagatta praneshdc4fceb2018-10-16 18:06:18 +080067 PCI_DEVICE_ID_INTEL_CNP_H_AUDIO,
Aamir Bohra9eac0392018-06-30 12:07:04 +053068 PCI_DEVICE_ID_INTEL_ICL_AUDIO,
Ronak Kanabarda7ffb482019-02-05 01:51:13 +053069 PCI_DEVICE_ID_INTEL_CMP_AUDIO,
Gaggery Tsai12a651c2019-12-05 11:23:20 -080070 PCI_DEVICE_ID_INTEL_CMP_H_AUDIO,
Frans Hendriks59ae2ef2019-02-28 15:16:00 +010071 PCI_DEVICE_ID_INTEL_BSW_AUDIO,
Ravi Sarawadi6b5bf402019-10-21 22:25:04 -070072 PCI_DEVICE_ID_INTEL_TGL_AUDIO,
Tan, Lean Sheng26136092020-01-20 19:13:56 -080073 PCI_DEVICE_ID_INTEL_MCC_AUDIO,
Duncan Laurie93142a42018-01-08 17:41:58 -080074 0
75};
76
77static const struct pci_driver pch_hda __pci_driver = {
78 .ops = &hda_ops,
79 .vendor = PCI_VENDOR_ID_INTEL,
80 .devices = pci_device_ids,
81};