coreboot
coreboot is an Open Source project aimed at replacing the proprietary BIOS found in most computers.
minihd.c
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 
3 #include <console/console.h>
4 #include <device/azalia_device.h>
5 #include <device/device.h>
6 #include <device/pci.h>
7 #include <device/pci_ids.h>
8 #include <device/pci_ops.h>
9 #include <device/mmio.h>
10 #include <soc/igd.h>
12 
13 static const u32 minihd_verb_table[] = {
14  /* coreboot specific header */
15  0x80862808, /* Codec Vendor / Device ID: Intel Broadwell Mini-HD */
16  0x80860101, /* Subsystem ID */
17  4, /* Number of jacks */
18 
19  /* Enable 3rd Pin and Converter Widget */
20  0x00878101,
21 
22  /* Pin Widget 5 - PORT B */
23  0x00571c10,
24  0x00571d00,
25  0x00571e56,
26  0x00571f18,
27 
28  /* Pin Widget 6 - PORT C */
29  0x00671c20,
30  0x00671d00,
31  0x00671e56,
32  0x00671f18,
33 
34  /* Pin Widget 7 - PORT D */
35  0x00771c30,
36  0x00771d00,
37  0x00771e56,
38  0x00771f18,
39 
40  /* Disable 3rd Pin and Converter Widget */
41  0x00878100,
42 
43  /* Dummy entries to fill out the table */
44  0x00878100,
45  0x00878100,
46 };
47 
48 static void minihd_init(struct device *dev)
49 {
50  struct resource *res;
51  u32 reg32;
52  u8 *base;
53  int codec_mask, i;
54 
55  /* Find base address */
57  if (!res)
58  return;
59 
60  base = res2mmio(res, 0, 0);
61  printk(BIOS_DEBUG, "Mini-HD: base = %p\n", base);
62 
63  /* Set Bus Master */
65 
66  /* Mini-HD configuration */
67  reg32 = read32(base + 0x100c);
68  reg32 &= 0xfffc0000;
69  reg32 |= 0x4;
70  write32(base + 0x100c, reg32);
71 
72  reg32 = read32(base + 0x1010);
73  reg32 &= 0xfffc0000;
74  reg32 |= 0x4b;
75  write32(base + 0x1010, reg32);
76 
77  /* Init the codec and write the verb table */
78  codec_mask = hda_codec_detect(base);
79 
80  if (codec_mask) {
81  for (i = 3; i >= 0; i--) {
82  if (codec_mask & (1 << i))
84  sizeof(minihd_verb_table));
85  }
86  }
87 
88  /* Set EM4/EM5 registers */
89  write32(base + 0x0100c, igd_get_reg_em4());
90  write32(base + 0x01010, igd_get_reg_em5());
91 }
92 
93 static struct device_operations minihd_ops = {
95  .set_resources = pci_dev_set_resources,
96  .enable_resources = pci_dev_enable_resources,
97  .init = minihd_init,
98  .ops_pci = &pci_dev_ops_pci,
99 };
100 
101 static const unsigned short pci_device_ids[] = {
102  0x0a0c, /* Haswell */
103  0x160c, /* Broadwell */
104  0
105 };
106 
107 static const struct pci_driver minihd_driver __pci_driver = {
108  .ops = &minihd_ops,
109  .vendor = PCI_VID_INTEL,
110  .devices = pci_device_ids,
111 };
static void write32(void *addr, uint32_t val)
Definition: mmio.h:40
static uint32_t read32(const void *addr)
Definition: mmio.h:22
void azalia_codec_init(u8 *base, int addr, const u32 *verb_table, u32 verb_table_bytes)
#define printk(level,...)
Definition: stdlib.h:16
struct resource * probe_resource(const struct device *dev, unsigned int index)
See if a resource structure already exists for a given index.
Definition: device_util.c:323
static __always_inline void pci_or_config16(const struct device *dev, u16 reg, u16 ormask)
Definition: pci_ops.h:180
#define BIOS_DEBUG
BIOS_DEBUG - Verbose output.
Definition: loglevel.h:128
#define PCI_COMMAND_MASTER
Definition: pci_def.h:13
#define PCI_BASE_ADDRESS_0
Definition: pci_def.h:63
#define PCI_COMMAND
Definition: pci_def.h:10
void pci_dev_enable_resources(struct device *dev)
Definition: pci_device.c:721
void pci_dev_read_resources(struct device *dev)
Definition: pci_device.c:534
struct pci_operations pci_dev_ops_pci
Default device operation for PCI devices.
Definition: pci_device.c:911
void pci_dev_set_resources(struct device *dev)
Definition: pci_device.c:691
#define PCI_VID_INTEL
Definition: pci_ids.h:2157
static void * res2mmio(const struct resource *res, unsigned long offset, unsigned long mask)
Definition: resource.h:87
uintptr_t base
Definition: uart.c:17
u32 igd_get_reg_em5(void)
Definition: gma.c:40
u32 igd_get_reg_em4(void)
Definition: gma.c:39
static const u32 minihd_verb_table[]
Definition: minihd.c:13
static const unsigned short pci_device_ids[]
Definition: minihd.c:101
static const struct pci_driver minihd_driver __pci_driver
Definition: minihd.c:107
static struct device_operations minihd_ops
Definition: minihd.c:93
static void minihd_init(struct device *dev)
Definition: minihd.c:48
int hda_codec_detect(u8 *base)
Definition: hda_verb.c:10
uint32_t u32
Definition: stdint.h:51
uint8_t u8
Definition: stdint.h:45
void(* read_resources)(struct device *dev)
Definition: device.h:39
Definition: device.h:107