Angel Pons | 0612b27 | 2020-04-05 15:46:56 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
Duncan Laurie | 93142a4 | 2018-01-08 17:41:58 -0800 | [diff] [blame] | 2 | |
| 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 Laurie | 93142a4 | 2018-01-08 17:41:58 -0800 | [diff] [blame] | 8 | #include <soc/intel/common/hda_verb.h> |
| 9 | #include <soc/ramstage.h> |
| 10 | |
Julius Werner | cd49cce | 2019-03-05 16:53:33 -0800 | [diff] [blame] | 11 | #if CONFIG(SOC_INTEL_COMMON_BLOCK_HDA_VERB) |
Duncan Laurie | 93142a4 | 2018-01-08 17:41:58 -0800 | [diff] [blame] | 12 | static 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 | |
| 27 | static 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 Shaikh | 31bff01 | 2018-09-29 23:31:04 -0700 | [diff] [blame] | 47 | #endif |
Duncan Laurie | 93142a4 | 2018-01-08 17:41:58 -0800 | [diff] [blame] | 48 | |
| 49 | static struct device_operations hda_ops = { |
Elyes HAOUAS | 1d19127 | 2018-11-27 12:23:48 +0100 | [diff] [blame] | 50 | .read_resources = pci_dev_read_resources, |
| 51 | .set_resources = pci_dev_set_resources, |
| 52 | .enable_resources = pci_dev_enable_resources, |
Julius Werner | cd49cce | 2019-03-05 16:53:33 -0800 | [diff] [blame] | 53 | #if CONFIG(SOC_INTEL_COMMON_BLOCK_HDA_VERB) |
Elyes HAOUAS | 1d19127 | 2018-11-27 12:23:48 +0100 | [diff] [blame] | 54 | .init = hda_init, |
Furquan Shaikh | 31bff01 | 2018-09-29 23:31:04 -0700 | [diff] [blame] | 55 | #endif |
Duncan Laurie | 93142a4 | 2018-01-08 17:41:58 -0800 | [diff] [blame] | 56 | .ops_pci = &pci_dev_ops_pci, |
Nico Huber | f7ed3d4 | 2019-03-14 15:50:06 +0100 | [diff] [blame] | 57 | .scan_bus = enable_static_devices, |
Duncan Laurie | 93142a4 | 2018-01-08 17:41:58 -0800 | [diff] [blame] | 58 | }; |
| 59 | |
| 60 | static const unsigned short pci_device_ids[] = { |
| 61 | PCI_DEVICE_ID_INTEL_SKL_AUDIO, |
Praveen hodagatta pranesh | ccd7cd8 | 2018-11-23 17:30:39 +0800 | [diff] [blame] | 62 | PCI_DEVICE_ID_INTEL_SKL_H_AUDIO, |
Maxim Polyakov | 571d07d | 2019-08-22 13:11:32 +0300 | [diff] [blame] | 63 | PCI_DEVICE_ID_INTEL_LWB_AUDIO, |
| 64 | PCI_DEVICE_ID_INTEL_LWB_AUDIO_SUPER, |
Duncan Laurie | 93142a4 | 2018-01-08 17:41:58 -0800 | [diff] [blame] | 65 | PCI_DEVICE_ID_INTEL_KBL_AUDIO, |
| 66 | PCI_DEVICE_ID_INTEL_CNL_AUDIO, |
praveen hodagatta pranesh | dc4fceb | 2018-10-16 18:06:18 +0800 | [diff] [blame] | 67 | PCI_DEVICE_ID_INTEL_CNP_H_AUDIO, |
Aamir Bohra | 9eac039 | 2018-06-30 12:07:04 +0530 | [diff] [blame] | 68 | PCI_DEVICE_ID_INTEL_ICL_AUDIO, |
Ronak Kanabar | da7ffb48 | 2019-02-05 01:51:13 +0530 | [diff] [blame] | 69 | PCI_DEVICE_ID_INTEL_CMP_AUDIO, |
Gaggery Tsai | 12a651c | 2019-12-05 11:23:20 -0800 | [diff] [blame] | 70 | PCI_DEVICE_ID_INTEL_CMP_H_AUDIO, |
Frans Hendriks | 59ae2ef | 2019-02-28 15:16:00 +0100 | [diff] [blame] | 71 | PCI_DEVICE_ID_INTEL_BSW_AUDIO, |
Ravi Sarawadi | 6b5bf40 | 2019-10-21 22:25:04 -0700 | [diff] [blame] | 72 | PCI_DEVICE_ID_INTEL_TGL_AUDIO, |
Tan, Lean Sheng | 2613609 | 2020-01-20 19:13:56 -0800 | [diff] [blame] | 73 | PCI_DEVICE_ID_INTEL_MCC_AUDIO, |
Duncan Laurie | 93142a4 | 2018-01-08 17:41:58 -0800 | [diff] [blame] | 74 | 0 |
| 75 | }; |
| 76 | |
| 77 | static const struct pci_driver pch_hda __pci_driver = { |
| 78 | .ops = &hda_ops, |
| 79 | .vendor = PCI_VENDOR_ID_INTEL, |
| 80 | .devices = pci_device_ids, |
| 81 | }; |