2020-04-02 23:48:50 +02:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0-only */
|
2013-06-20 21:40:55 +02:00
|
|
|
|
|
|
|
#include <console/console.h>
|
|
|
|
#include <device/device.h>
|
|
|
|
#include <device/pci.h>
|
|
|
|
#include <device/pci_ids.h>
|
|
|
|
#include <device/pci_ops.h>
|
2019-03-03 07:01:05 +01:00
|
|
|
#include <device/mmio.h>
|
2013-06-20 21:40:55 +02:00
|
|
|
#include <southbridge/intel/lynxpoint/hda_verb.h>
|
|
|
|
|
|
|
|
static const u32 minihd_verb_table[] = {
|
|
|
|
/* coreboot specific header */
|
2020-01-15 00:49:03 +01:00
|
|
|
0x80862807, /* Codec Vendor / Device ID: Intel Haswell Mini-HD */
|
|
|
|
0x80860101, /* Subsystem ID */
|
|
|
|
4, /* Number of jacks */
|
2013-06-20 21:40:55 +02:00
|
|
|
|
|
|
|
/* Enable 3rd Pin and Converter Widget */
|
|
|
|
0x00878101,
|
|
|
|
|
|
|
|
/* Pin Widget 5 - PORT B */
|
2020-01-15 00:49:03 +01:00
|
|
|
0x00571c10,
|
|
|
|
0x00571d00,
|
|
|
|
0x00571e56,
|
|
|
|
0x00571f18,
|
2013-06-20 21:40:55 +02:00
|
|
|
|
|
|
|
/* Pin Widget 6 - PORT C */
|
2020-01-15 00:49:03 +01:00
|
|
|
0x00671c20,
|
|
|
|
0x00671d00,
|
|
|
|
0x00671e56,
|
|
|
|
0x00671f18,
|
2013-06-20 21:40:55 +02:00
|
|
|
|
|
|
|
/* Pin Widget 7 - PORT D */
|
2020-01-15 00:49:03 +01:00
|
|
|
0x00771c30,
|
|
|
|
0x00771d00,
|
|
|
|
0x00771e56,
|
|
|
|
0x00771f18,
|
2013-06-20 21:40:55 +02:00
|
|
|
|
|
|
|
/* Disable 3rd Pin and Converter Widget */
|
|
|
|
0x00878100,
|
|
|
|
|
|
|
|
/* Dummy entries to fill out the table */
|
|
|
|
0x00878100,
|
|
|
|
0x00878100,
|
|
|
|
};
|
|
|
|
|
|
|
|
static void minihd_init(struct device *dev)
|
|
|
|
{
|
|
|
|
struct resource *res;
|
2014-12-25 03:43:20 +01:00
|
|
|
u32 reg32;
|
|
|
|
u8 *base;
|
2013-06-20 21:40:55 +02:00
|
|
|
int codec_mask, i;
|
|
|
|
|
|
|
|
/* Find base address */
|
|
|
|
res = find_resource(dev, PCI_BASE_ADDRESS_0);
|
|
|
|
if (!res)
|
|
|
|
return;
|
|
|
|
|
2014-12-25 03:43:20 +01:00
|
|
|
base = res2mmio(res, 0, 0);
|
|
|
|
printk(BIOS_DEBUG, "Mini-HD: base = %p\n", base);
|
2013-06-20 21:40:55 +02:00
|
|
|
|
|
|
|
/* Set Bus Master */
|
2020-06-20 18:03:27 +02:00
|
|
|
pci_or_config16(dev, PCI_COMMAND, PCI_COMMAND_MASTER);
|
2013-06-20 21:40:55 +02:00
|
|
|
|
|
|
|
/* Mini-HD configuration */
|
|
|
|
reg32 = read32(base + 0x100c);
|
|
|
|
reg32 &= 0xfffc0000;
|
|
|
|
reg32 |= 0x4;
|
|
|
|
write32(base + 0x100c, reg32);
|
|
|
|
|
|
|
|
reg32 = read32(base + 0x1010);
|
|
|
|
reg32 &= 0xfffc0000;
|
|
|
|
reg32 |= 0x4b;
|
|
|
|
write32(base + 0x1010, reg32);
|
|
|
|
|
|
|
|
/* Init the codec and write the verb table */
|
|
|
|
codec_mask = hda_codec_detect(base);
|
|
|
|
|
|
|
|
if (codec_mask) {
|
|
|
|
for (i = 3; i >= 0; i--) {
|
|
|
|
if (codec_mask & (1 << i))
|
2020-01-15 00:49:03 +01:00
|
|
|
hda_codec_init(base, i, sizeof(minihd_verb_table),
|
2013-06-20 21:40:55 +02:00
|
|
|
minihd_verb_table);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct device_operations minihd_ops = {
|
|
|
|
.read_resources = pci_dev_read_resources,
|
|
|
|
.set_resources = pci_dev_set_resources,
|
|
|
|
.enable_resources = pci_dev_enable_resources,
|
|
|
|
.init = minihd_init,
|
2020-05-31 00:03:28 +02:00
|
|
|
.ops_pci = &pci_dev_ops_pci,
|
2013-06-20 21:40:55 +02:00
|
|
|
};
|
|
|
|
|
2018-10-30 14:22:13 +01:00
|
|
|
static const unsigned short pci_device_ids[] = { 0x0a0c, 0x0c0c, 0 };
|
2013-06-20 21:40:55 +02:00
|
|
|
|
|
|
|
static const struct pci_driver haswell_minihd __pci_driver = {
|
|
|
|
.ops = &minihd_ops,
|
|
|
|
.vendor = PCI_VENDOR_ID_INTEL,
|
|
|
|
.devices = pci_device_ids,
|
|
|
|
};
|