2 * This file is part of the coreboot project.
4 * Copyright (C) 2008 Advanced Micro Devices, Inc.
5 * Copyright (C) 2008-2009 coresystems GmbH
6 * Copyright (C) 2011 The ChromiumOS Authors. All rights reserved.
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; version 2 of the License.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
18 #include <console/console.h>
19 #include <device/device.h>
20 #include <device/pci.h>
21 #include <device/pci_ids.h>
22 #include <device/pci_ops.h>
26 #include <southbridge/intel/lynxpoint/hda_verb.h>
28 static const u32 minihd_verb_table
[] = {
29 /* coreboot specific header */
30 0x80862807, // Codec Vendor / Device ID: Intel Haswell Mini-HD
31 0x00000000, // Subsystem ID
32 0x00000004, // Number of jacks
34 /* Enable 3rd Pin and Converter Widget */
37 /* Pin Widget 5 - PORT B */
43 /* Pin Widget 6 - PORT C */
49 /* Pin Widget 7 - PORT D */
55 /* Disable 3rd Pin and Converter Widget */
58 /* Dummy entries to fill out the table */
63 static void minihd_init(struct device
*dev
)
70 /* Find base address */
71 res
= find_resource(dev
, PCI_BASE_ADDRESS_0
);
75 base
= res2mmio(res
, 0, 0);
76 printk(BIOS_DEBUG
, "Mini-HD: base = %p\n", base
);
79 reg32
= pci_read_config32(dev
, PCI_COMMAND
);
80 pci_write_config32(dev
, PCI_COMMAND
, reg32
| PCI_COMMAND_MASTER
);
82 /* Mini-HD configuration */
83 reg32
= read32(base
+ 0x100c);
86 write32(base
+ 0x100c, reg32
);
88 reg32
= read32(base
+ 0x1010);
91 write32(base
+ 0x1010, reg32
);
93 /* Init the codec and write the verb table */
94 codec_mask
= hda_codec_detect(base
);
97 for (i
= 3; i
>= 0; i
--) {
98 if (codec_mask
& (1 << i
))
99 hda_codec_init(base
, i
,
100 sizeof(minihd_verb_table
),
106 static void minihd_set_subsystem(device_t dev
, unsigned vendor
, unsigned device
)
108 if (!vendor
|| !device
) {
109 pci_write_config32(dev
, PCI_SUBSYSTEM_VENDOR_ID
,
110 pci_read_config32(dev
, PCI_VENDOR_ID
));
112 pci_write_config32(dev
, PCI_SUBSYSTEM_VENDOR_ID
,
113 ((device
& 0xffff) << 16) | (vendor
& 0xffff));
117 static struct pci_operations minihd_pci_ops
= {
118 .set_subsystem
= minihd_set_subsystem
,
121 static struct device_operations minihd_ops
= {
122 .read_resources
= pci_dev_read_resources
,
123 .set_resources
= pci_dev_set_resources
,
124 .enable_resources
= pci_dev_enable_resources
,
127 .ops_pci
= &minihd_pci_ops
,
130 static const unsigned short pci_device_ids
[] = { 0x0a0c, 0 };
132 static const struct pci_driver haswell_minihd __pci_driver
= {
134 .vendor
= PCI_VENDOR_ID_INTEL
,
135 .devices
= pci_device_ids
,